package com.beike.entity;

import com.baomidou.mybatisplus.annotation.EnumValue;

public enum UserRole {
    ADMIN("ADMIN"),
    TEACHER("TEACHER"),
    STUDENT("STUDENT"),
    USER("USER");

    @EnumValue
    private final String value;

    UserRole(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public static UserRole fromValue(String value) {
        if (value == null) {
            throw new IllegalArgumentException("Role value cannot be null");
        }
        
        try {
            return UserRole.valueOf(value);
        } catch (IllegalArgumentException ignored) {
            for (UserRole role : UserRole.values()) {
                if (role.value.equals(value)) {
                    return role;
                }
            }
            throw new IllegalArgumentException("Invalid UserRole value: " + value);
        }
    }
} 